﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RATSharp.Model
{
    /// <summary>
    /// Do a mapping for Model which will be serialised
    /// </summary>
    public class ReservationFactory
    {
        /// <summary>
        /// Create new Reservation collection
        /// </summary>
        /// <param name="since">period since</param>
        /// <param name="to">period to</param>
        /// <param name="numberOfWeeks">nember of weeks</param>
        /// <param name="obj">object to reserve</param>
        /// <param name="pickAction">is reservation already picked?</param>
        /// <returns></returns>
        public static Reservations createReservations(DateTime since, DateTime to, int numberOfWeeks, Model.Object obj, PickAction pickAction)
        {
            Reservations reservations = new Reservations();
            //reservations.reservationList = new List<Reservation>();
            Reservation reservation = new Reservation();
            reservations.Add(reservation);
            reservation.objectId = obj.id;
            reservation.objectName = obj.name;
            reservation.periods = new Periods();
            //periods.periodList = new List<Period>();
            for (int i = 0; i < numberOfWeeks; i++)
            {
                Period period = new Period();
                period.fromDate = since;

                period.toDate = to;
                period.valid = true;
                period.pickAction = pickAction;
                period.returnAction = ReturnAction.NOT_RETURNED;

                reservation.periods.Add(period);
                since = since.AddDays(7);
                to = to.AddDays(7);
            }
            return reservations;
        }


    }
}
